//
//  SDTableViewCell.m
//  YYPHSpeedJump
//
//  Created by speedjump on 15/12/24.
//  Copyright © 2015年 sujiang. All rights reserved.
//

#import "SDTableViewCell.h"
#import "PurchaseHomeViewController.h"
@implementation SDTableViewCell


- (void)awakeFromNib {
    // Initialization code
    _headerView.backgroundColor =kColors(239, 239, 244, 1);
    self.goodImage.contentMode = UIViewContentModeScaleAspectFit;
     self.imageNub.layer.cornerRadius = 7.5;
    self.imageNub.layer.masksToBounds = YES;
    }
- (void)setModel:(SDModel *)model
{
    self.comment.text = model.comment;
    //self.prasieNub.text = [NSString stringWithFormat:@"(%@)", model.up_num];
    self.userName.text = model.nickname;
    self.goodName.text = model.name;
    self.xianmuNub.text = [NSString stringWithFormat:@"(%@)",model.xianmu_num];
    self.jiduNub.text =[NSString stringWithFormat:@"(%@)",model.jidu_num];
    self.henNub.text =[NSString stringWithFormat:@"(%@)",model.hen_num];
    [self.topImage sd_setImageWithURL:[NSURL URLWithString:model.head_img_url] placeholderImage:nil];
    self.timeLable.text = model.create_time;
    self.buyPrice.text = [NSString stringWithFormat:@"购入价:%@",model.buy_price];
    CGFloat sheng = [model.original_price integerValue] - [model.buy_price integerValue];
    self.shengPrice.textAlignment = NSTextAlignmentCenter;
    self.shengPrice.text = [NSString stringWithFormat:@"省￥%.f",sheng];
    NSArray *arr= [model.img_url_list componentsSeparatedByString:@";"];
    [self.goodImage sd_setImageWithURL:[NSURL URLWithString:arr[0]] placeholderImage:nil];
    CGFloat ratio =sheng/[model.original_price integerValue];
    if (ratio<0.1) {
        self.xzImage.image = [UIImage imageNamed:@"xz06"];

    }
    if (0.1<=ratio && ratio<0.3) {
        self.xzImage.image = [UIImage imageNamed:@"xz01"];
    }
    if (0.3<=ratio && ratio<0.5) {
        self.xzImage.image = [UIImage imageNamed:@"xz02"];
    }
    if (0.5<=ratio && ratio<0.75) {
        self.xzImage.image = [UIImage imageNamed:@"xz03"];
    }
    if (0.75<=ratio && ratio<1) {
        self.xzImage.image = [UIImage imageNamed:@"xz04"];
    }
    if (ratio==1) {
        self.xzImage.image = [UIImage imageNamed:@"xz05"];
    }
    
    if (arr.count == 0) {
        self.imageNub.hidden =YES;
    }
    
    if (arr.count == 1) {
       self.imageNub.text = @"1";

    }
    if (arr.count ==2) {
        self.imageNub.text = @"2";
    }
    if (arr.count ==3) {
       self.imageNub.text = @"3";
    }
    
    _model = model;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
